package GUIadapter;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import ModelLayer.RentItem;

@SuppressWarnings("serial")
public class RentItemModel extends AbstractTableModel
{
	private final String[] columnHeader = { "Varenummer",
											"Beskrivelse",
											"Pris",
											"Antal",
											"Lokation",
											"Serienummer",
											"Udlejet"
											};

	private List<RentItem> rentItemList;

	public RentItemModel(List<RentItem> rentItemList)
	{
		this.rentItemList = rentItemList;
	}

	@Override
	public String getColumnName(int column)
	{
		// TODO Auto-generated method stub
		return columnHeader[column];
	}

	@Override
	public int getColumnCount()
	{
		// TODO Auto-generated method stub
		return columnHeader.length;
	}

	@Override
	public int getRowCount()
	{
		// TODO Auto-generated method stub
		return rentItemList.size();
	}

	@Override
	public Object getValueAt(int row, int col)
	{
		// TODO Auto-generated method stub
		RentItem rentItem = rentItemList.get(row);
		switch(col)
		{
		case 0:
			return new Integer(rentItem.getItemnr());
		case 1:
			return rentItem.getDescription();
		case 2:
			return rentItem.getPrice();
		case 3:
			return rentItem.getInStock();
		case 4:
			return rentItem.getLocation();
		case 5:
			return rentItem.getSerialnr();
		case 6:
			return rentItem.getRented();
		}
		return null;
	}

}

